package com.yowasa.xiuxian.engine.item.lingyao;

import com.google.common.collect.Sets;
import com.yowasa.xiuxian.annoations.Item;
import com.yowasa.xiuxian.engine.item.ItemInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.bo.user.UserBattle;
import com.yowasa.xiuxian.entity.bo.user.UserConfig;
import com.yowasa.xiuxian.entity.enums.ItemTypeEnum;

import java.util.Date;
import java.util.Set;

@Item(name = "九转轮回丹", type = ItemTypeEnum.LING_YAO, price = 50000)
public class JiuZhuanLunHuiDan implements ItemInterface {

    @Override
    public String desc() {
        return "重生的同时保留记忆";
    }

    @Override
    public String effect(UserBO userBO) {
        //重制境界
        userBO.setStage(1);
        userBO.setLevel(0);
        //重制年龄
        userBO.setStartAt(new Date());
        //重制战斗属性
        userBO.setUserOriginBattle(UserBattle.genBattleAttr(userBO.getUserAttr()));
        userBO.setUserBattle(userBO.getUserOriginBattle());
        //忘却心法
        UserConfig orgConfig = userBO.getUserConfig();
        userBO.setUserConfig(new UserConfig());
        //保留金钱
        userBO.getUserConfig().setGold(orgConfig.getGold());
        //保留耐药性
        userBO.getUserConfig().setLingYaoTag(orgConfig.getLingYaoTag());
        //保留历练
        userBO.getUserConfig().setTravel(orgConfig.getTravel());
        //保留可学习战技
        Set<String> strategyList = Sets.newHashSet();
        strategyList.addAll(orgConfig.getBattleStrategyList());
        strategyList.addAll(orgConfig.getCanStudyStrategies());
        userBO.getUserConfig().setCanStudyStrategies(strategyList);
        //保留可学习锻造图纸
        Set<String> equipList = Sets.newHashSet();
        equipList.addAll(orgConfig.getKnownEquipDrawing());
        userBO.getUserConfig().setKnownEquipDrawing(equipList);
        //保留可学习神通
        Set<String> specialEffects = Sets.newHashSet();
        specialEffects.addAll(orgConfig.getKnownSpecialEffect());
        specialEffects.addAll(orgConfig.getStudiedSpecialEffect());
        userBO.getUserConfig().setKnownSpecialEffect(orgConfig.getKnownSpecialEffect());
        userBO.setLockEndTime(new Date());
        return "回到了20岁,请自行查看";
    }




}
